
import {getPackageJSON,resolvePkgPath,getBaseRollupPluins} from './utils'
import rollupPluginGeneratePackageJson from "rollup-plugin-generate-package-json"
import alias from '@rollup/plugin-alias'

const {name,module,peerDependencies}  = getPackageJSON("react-noop-renderer")

//react-noop-renderer 包路径
const pkgPath = resolvePkgPath(name)
//react-noop-renderer 包的dist路径
const pkgDistPath = resolvePkgPath(name,true)


export default [
    //react-noop-renderer
    {
        input:`${pkgPath}/${module}`,
        output:[
            {
                file:`${pkgDistPath}/index.js`,
                name:"ReactNoopRenderer",
                format:"umd"
            }
        ],
        external:[...Object.keys(peerDependencies),"scheduler"],

        plugins:[...getBaseRollupPluins({
                typescript:{
                    exclude:["./packages/react-dom/**/*"],
                    tsconfigOverride: {
                        compilerOptions: {
                            paths:{
                                hostConfig:[`./${name}/src/hostConfig.ts`]
                            }
                        }
                    }
                }
            }),
            //webpack resolve alias
            alias({
                entries:{
                    hostConfig:`${pkgPath}/src/hostConfig.ts`
                }
            }),
            rollupPluginGeneratePackageJson({
            inputFolder:pkgPath,
            outputFolder:pkgDistPath,
            baseContents:({name,description,version})=>({
                name,
                description,
                version,
                peerDependencies:{
                    react:version
                },
                main:"index.js"
            })
        })]
    }
]